@file:Suppress("DEPRECATION")

package com.zhsm.fuxi.view.widget

import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import com.zhsm.fuxi.R
import kotlinx.android.synthetic.main.view_havacar_marke.view.*


/**
 * Created by GuZhC on 2018/10/15.
 * describe:地图Maker
 */
class MyMapmarkerView(context: Context?, attrs: AttributeSet?) : RelativeLayout(context, attrs) {
    init {
        LayoutInflater.from(context).inflate(R.layout.view_havacar_marke, this, true)
    }

    @SuppressLint("ResourceAsColor")
    fun setCarNum(num: Int) {
        if (num > 0) {
            markerBg.setImageResource(R.mipmap.map_havecar)
            markerCarNum.setTextColor(resources.getColor(R.color.text_orange))
            markerCarNum.text = num.toString()
        } else {
            markerBg.setImageResource(R.mipmap.map_nocar)
            markerCarNum.setTextColor(resources.getColor(R.color.text_grey))
            markerCarNum.text = "0"
        }
    }

    fun getCarNum(): Int {
        return Integer.getInteger(markerCarNum.text.toString())
    }
}